﻿using System;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Ink;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections.Generic;

namespace WeatherFrame
{
    /// <summary>
    /// A weather condition, summarising the state of the weather at a location
    /// for a particular time period.
    /// </summary>
    public class WeatherCondition
    {
        public int Code { get; private set; }
        public string Description { get; private set; }

        public string CondKey { get; private set; }

        private WeatherCondition(int code, string desc, string condKey)
        {
            this.Description = desc;
            this.Code = code;
            this.CondKey = condKey;
        }

        public static WeatherCondition FromWeatherCode(int weatherCode)
        {
            foreach (var c in Conditions) if (c.Code == weatherCode) return c;
            return Conditions[0];
        }


        /// <summary>
        /// List of all weather conditions
        /// </summary>
        public static List<WeatherCondition> Conditions = new List<WeatherCondition>() {
            new WeatherCondition(-1,"Unknown",null),
            new WeatherCondition(113,"Clear/Sunny","Sun"),
            new WeatherCondition(116,"Partly Cloudy","CloudSun"),
            new WeatherCondition(119,"Cloudy","Cloud"),
            new WeatherCondition(122,"Overcast","GreyCloud"),
            new WeatherCondition(143,"Mist","Mist"),
            new WeatherCondition(176,"Patchy rain nearby","CloudSunRain"),
            new WeatherCondition(179,"Patchy snow nearby","CloudSunSnow"),
            new WeatherCondition(182,"Patchy sleet nearby","GreyCloudSunSleet"),
            new WeatherCondition(185,"Patchy freezing drizzle nearby","GreyCloudSunSleet"),
            new WeatherCondition(200,"Thundery outbreaks nearby","ThundercloudSun"),
            new WeatherCondition(227,"Blowing snow","CloudSnow"),
            new WeatherCondition(230,"Blizzard","GreyCloudSnow"),
            new WeatherCondition(248,"Fog","Fog"),
            new WeatherCondition(260,"Freezing fog","Fog"),
            new WeatherCondition(263,"Patchy light drizzle","CloudSunRain"),
            new WeatherCondition(266,"Light drizzle","CloudRain"),
            new WeatherCondition(281,"Freezing drizzle","CloudSleet"),
            new WeatherCondition(284,"Heavy freezing drizzle","GreyCloudSleet"),
            new WeatherCondition(293,"Patchy light rain","CloudRain"),
            new WeatherCondition(296,"Light rain","CloudRain"),
            new WeatherCondition(299,"Modearte rain at times","GreyCloudSunRain"),
            new WeatherCondition(302,"Moderate rain","GreyCloudRain"),
            new WeatherCondition(305,"Heavy rain at times","GreyCloudSunRain"),
            new WeatherCondition(308,"Heavy rain","GreyCloudRain"),
            new WeatherCondition(311,"Light freezing rain","CloudSleet"),
            new WeatherCondition(314,"Moderate or Heavy freezing rain","GreyCloudSleet"),
            new WeatherCondition(317,"Light sleet","CloudSleet"),
            new WeatherCondition(320,"Moderate or heavy sleet","GreyCloudSleet"),
            new WeatherCondition(323,"Patchy light snow","CloudSunSnow"),
            new WeatherCondition(326,"Light snow","CloudSnow"),
            new WeatherCondition(329,"Patchy moderate snow","GreyCloudSunSnow"),
            new WeatherCondition(332,"Moderate snow","GreyCloudSnow"),
            new WeatherCondition(335,"Patchy heavy snow","GreyCloudSunSnow"),
            new WeatherCondition(338,"Heavy snow","GreyCloudSnow"),
            new WeatherCondition(350,"Ice pellets","GreyCloudHail"),
            new WeatherCondition(353,"Light rain shower","CloudSunRain"),
            new WeatherCondition(356,"Moderate or heavy rain shower","GreyCloudSunRain"),
            new WeatherCondition(359,"Torrential rain shower","GreyCloudRain"),
            new WeatherCondition(362,"Light sleet showers","GreyCloudSunSleet"),
            new WeatherCondition(365,"Moderate or heavy sleet showers","GreyCloudSunSleet"),
            new WeatherCondition(368,"Light snow showers","CloudSnow"),
            new WeatherCondition(371,"Moderate or heavy snow showers","GreyCloudSnow"),
            new WeatherCondition(374,"Light showers of ice pellets","GreyCloudSunHail"),
            new WeatherCondition(377,"Moderate or heavy showers of ice pellets","GreyCloudSunHail"),
            new WeatherCondition(386,"Patchy light rain with thunder","ThundercloudSun"),
            new WeatherCondition(389,"Moderate or heavy rain with thunder","Thundercloud"),
            new WeatherCondition(392,"Patchy light snow with thunder","ThundercloudSun"),
            new WeatherCondition(395,"Moderate or heavy snow with thunder","GreyCloudSnow")                              
        };
    }
}
